/**
 * File: ContigDataReader.java
 * Created by: mhaimel
 * Created on: 18 Aug 2009
 * CVS:  $Id: ContigDataReader.java,v 1.1 2009/08/27 14:52:44 mhaimel Exp $
 */
package uk.ac.ebi.curtain.util.io;

import java.io.BufferedReader;
import java.io.File;
import java.util.Iterator;

import uk.ac.ebi.velvet.model.ContigData;
import uk.ac.ebi.velvet.model.impl.ContigDataImpl;

/**
 * @author mhaimel
 *
 */
public class ContigDataReader extends AbstractReader<ContigData> {

	public ContigDataReader(File in) {
		super(in);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected Iterator<ContigData> _buildIter(File inFile) {
		return new ContigDataIter(inFile);
	}
	
	public static class ContigDataIter extends AbstractIter<ContigData>{

		public ContigDataIter(File f, BufferedReader in) {
			super(f, in);
		}

		public ContigDataIter(File f) {
			super(f);
		}

		/* ID | length | filePos */
		@Override
		protected ContigData _buildEntry(String[] arr) {
			ContigDataImpl ctg = new ContigDataImpl();
			ctg.setIdentifier(Integer.valueOf(arr[0]));
			ctg.setLength(Integer.valueOf(arr[1]));
			ctg.setFilePosition(Long.valueOf(arr[2]));
			return ctg;
		}
		
	}
}
